<!DOCTYPE html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8"/>
        <title>通知列表页面</title>
        <meta name="renderer" content="webkit"/>
        <link rel="stylesheet" href="../../css/font.css"/>
        <link rel="stylesheet" href="../../css/xadmin.css"/>
        <script src="../../lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="../../js/xadmin.js"></script>
        <script src="../../js/vue2.7min.js"></script>
        <script src="../../js/axios.min.js"></script>
    </head>
    <body>
        <div class="x-nav">
            <a
                    class="layui-btn layui-btn-small"
                    style="line-height: 1.6em; margin-top: 3px; float: right"
                    onclick="location.reload()"
                    title="刷新">
                <i class="layui-icon layui-icon-refresh" style="line-height: 30px"></i></a>
        </div>
        <div class="layui-fluid" v-show="managerLevel===0" id="app">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            <button
                                    class="layui-btn"
                                    v-show="managerLevel===0"
                                    onclick="xadmin.open('添加','./notice-add.html',600,400)">
                                <i class="layui-icon"></i>添加
                            </button>
                        </div>
                        <div class="layui-card-body layui-table-body layui-table-main">
                            <table class="layui-table layui-form">
                                <thead>
                                <tr>
                                    <th>编号</th>
                                    <th>标题</th>
                                    <th>内容</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <!--模板开始-->
                                <tr v-for="(item , index) in noticeList">
                                    <td>{{index+1}}</td>
                                    <td v-text="item.noticeTitle"></td>
                                    <td v-text="item.noticeMessage"></td>
                                    <td class="td-manage">
                                        <span class="layui-btn layui-btn-normal layui-btn-mini"
                                              style="background-color: red"
                                              @click="deleteById(item.noticeId)">删除</span>
                                    </td>
                                </tr>
                                <!--模板结束-->
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <script type="text/javascript">
            var vm = new Vue({
                el: "#app",
                data: {
                    //Manager信息
                    managerId: null,
                    managerName: null,
                    managerPassword: null,
                    managerRealName: null,
                    managerSex: null,
                    managerPhone: null,
                    managerState: null,
                    managerLevel: null,
                    //列表数据
                    noticeList:null,

                },
                methods: {
                    //获取管理员信息
                    getManager() {
                        axios.post("../../../manager/getManager")
                            .then(function (response) {
                                //数据保存到vue全局
                                if (response.data.code === 1) {
                                    //Manager信息
                                    vm.managerId = response.data.data.managerId;
                                    vm.managerName = response.data.data.managerName
                                    vm.managerPassword = response.data.data.managerPassword
                                    vm.managerRealName = response.data.data.managerRealName
                                    vm.managerSex = response.data.data.managerSex
                                    vm.managerPhone = response.data.data.managerPhone
                                    vm.managerState = response.data.data.managerState
                                    vm.managerLevel = response.data.data.managerLevel
                                }
                            }, function (err) {
                                console.log(err);

                            })
                    },
                    getAllDesc() {
                        axios.post("../../../notice/getAllDesc")
                            .then(function (response) {
                                if (response.data.code===1){
                                    vm.noticeList=response.data.data;                                }

                            }, function (err) {
                                console.log(err);

                            })

                    },
                    deleteById(id) {
                        //修改管理员状态
                        var jsonD = {id: id}
                        axios.post("../../../notice/deleteById", jsonD)
                            .then(function (response) {
                                //数据保存到vue全局
                                if (response.data.code === 1) {
                                    xadmin.father_reload()

                                }
                            }, function (err) {
                                console.log(err);

                            })
                    }
                },
                mounted: function () {
                    //查询管理员信息
                    this.getManager();
                    //获取分页数据
                    this.getAllDesc();
                }
            });
        </script>
    </body>

</html>